Query Builder
The IQNOX Query Builder Widget is a powerful and intuitive tool designed to simplify complex query creation within the ThingWorx platform. Built on top of the popular jQuery QueryBuilder library, this widget provides a user-friendly, visual interface for building dynamic and nested queries without writing a single line of code.
Example
 
Usage
The Query Builder Widget empowers both technical and non-technical users to:
- Build advanced queries for infotables or data services
- Filter large datasets efficiently based on dynamic criteria
- Accelerate development time by eliminating the need for manual query coding
- Enable end-users to customize filters in dashboards or reports directly
Properties
| Properties | Type | Binding | Default | Description | 
|---|---|---|---|---|
| CustomClass | STRING | <> | Enables you to define an html class to the top div of the widget. Multiple classes can be entered, separated by space. | |
| Data | INFOTABLE | < | An InfoTable containing the list of fields that can be used in the query builder and conditions can be added on | |
| Query | QUERY | <> | Represents the current query. As users interact with the Query Builder, the Query is updated to reflect those changes. | |
| DisplayField | FIELDNAME | How should the field be shown to the user. If empty, the name will be used. | ||
| BaseTypeField | FIELDNAME | What baseType the field has, needed to identify what operators to show. | ||
| NameField | FIELDNAME | The name of the field, used inside the the Queryproperty when filters are created. | ||
| SectionField | FIELDNAME | Split the fields into sections. | ||
| ValuesField | FIELDNAME | The possible values if the field only allows a limited set of values. | ||
| AllowGroups | NUMBER | < | 1000 | Number of allowed nested groups. Setting it to 0 will disable nested groups. | 
| AllowAnd | BOOLEAN | < | true | Allow for AND conditions. | 
| AllowOr | BOOLEAN | < | true | Allow for OR conditions. | 
| ContainsValidQuery | BOOLEAN | > | Is the current query valid. | |
| IsQueryEmpty | BOOLEAN | > | The current query is empty (no rules). | |
| DatePickerFormat | STRING(localized) | < | DD/MM/YYYY HH:mm:ss | Display format for date values selected in a query. Format date using Format Complex. SimpleDateFormat rules are accepted, along with prefixes and suffixes. | 
| ReadOnly | BOOLEAN | false | If enabled, the query builder will be read-only. | 
Services
| Property | Type | Binding | Description | 
|---|---|---|---|
| ClearQuery | EVENT | < | Clears the query. | 
Events
| Property | Type | Binding | Description | 
|---|---|---|---|
| QueryChanged | EVENT | > | Triggered when the query has changed. | 
Fields configuration
The QueryBuilder widget allows the user to create a ThingWorx query object that can be used in other services.
In order to derive the list of fields that the users can select to build their queries, the developer must pass into the widget Data property an infotable where each row defines a field.
After binding the Data property, the following widget properties MUST to be set, and provided for each row in Data:
- NameField: maps to the column in the- Datainfotable that contains the name of the field. This is what ends up being used in the generated query.
- BaseTypeField: maps to the column that contains the type of the field (e.g., STRING, NUMBER, DATETIME, BOOLEAN, etc.). Drives what are the options avaialble for each field. Additionally, the following properties can be set to map to columns in- Datafor additonal customization:
- DisplayField: drive how the fields are shown to the user.
- SectionField: if fields should be grouped toghether in the field selection dropdown.
- ValuesField: allows the field to only have a specific list of values. If set, the value of this column in the infotable must be an INFOTABLE with the datashape- IQNOX_CommonDisplayValue_DS
IQNOX_CommonDisplayValue_DS
The datashape has the following fields:
value: STRING    // actual value
display: STRING  // text to show in the value dropdown
section: STRING  // under what section should it be located
Behavior
- If valid Datais provided forvalues, the Dropdown will display these server-provided options.
- If no matching entry is found in Datafor a column, the dropdown will fall back to the default behavior - using input from the user.
Important notes
- Inserting a query programmatically that has more groups than allowed in AllowGroupswill not register the entire query in the widget.